<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>发送私信</title>
<link rel="stylesheet" href="/static/layui/css/layui.css"></link>
<style type="text/css">

	table tr td{
		padding: 10px;
	}

</style>
</head>
<body>
<div style="padding: 20px">
	<form method="post">
		<table>
			<tr>
				<td>发送私信：</td>
				<td><textarea rows="5" cols="40" id="message" name="message" placeholder="请输入内容……"></textarea>
				</td>
			</tr>
			<tr>
				<td><button class="layui-btn" onclick="submitData();return false;">提交</button></td>
				<td><font id="errorInfo" color="red"></font></td>
			</tr>
		</table>
	</form>
</div>
<script src="/static/js/jquery.js"></script>
<script type="text/javascript">

	function submitData(){
		var message=$("#message").val().trim()
			if (message=="") { 
		　　　　     　　 $("#errorInfo").text("请输入内容！");
				  $("#message").focus();
		　　　　　　      return false; 
		　　　} 
		   var uid=getQueryVariable("uid");
		   $.post("/admin/user/addMessage",{uid:uid,message:message},function(result){
			  if(result.success){
				  alert("私信发送成功！");
				  reloadPage();
			  }else{
				  layer.msg("执行失败，请联系管理员！");
			  }
		  });
	}
	
	
	
	function getQueryVariable(variable){
	       var query = window.location.search.substring(1);
	       var vars = query.split("&");
	       for (var i=0;i<vars.length;i++) {
	               var pair = vars[i].split("=");
	               if(pair[0] == variable){return pair[1];}
	       }
	       return(false);
	}
	function reloadPage(){
		window.location.reload();
	}

</script>
</body>
</html>